package com.hlhj.funlike_businessqzxd.activity

import com.example.mymvp.okrx.BaseBean
import com.hlhj.funlike_businessqzxd.R
import com.hlhj.funlike_businessqzxd.presenter.ChangePwdPresenter
import com.hlhj.funlike_businessqzxd.toast
import com.hlhj.funlike_businessqzxd.views.ChangePwdView
import com.lzy.okgo.OkGo
import kotlinx.android.synthetic.main.aty_changepwd.*
import kotlinx.android.synthetic.main.head_title.*

class ChangePwdAty :BaseActivity<ChangePwdView,ChangePwdPresenter>(), ChangePwdView {

    override fun setChangeResult(baseBean: BaseBean) {
        "修改成功".toast()
        finish()
    }

    override fun initView() {
        tv_title.text="修改密码"
    }

    override fun logicStart() {
    }

    override fun setListener() {
        img_back.setOnClickListener {
            finish()
        }
        btCommit.setOnClickListener {
            if (oldPwd.text.toString().isEmpty()){
                "旧密码不能为空".toast()
                return@setOnClickListener
            }
            if (newPwd.text.toString().isEmpty()&&newPwdAg.text.toString().isEmpty()){
                "新密码不能为空".toast()
                return@setOnClickListener
            }
            if (!newPwd.text.toString().equals(newPwdAg.text.toString())){
                "两次密码不一样".toast()
                return@setOnClickListener
            }
            presenter?.changeP(this,oldPwd.text.toString(),newPwd.text.toString(),newPwdAg.text.toString())
        }
    }

    override fun getContentId(): Int {
        return R.layout.aty_changepwd
    }

    override fun createPresenter(): ChangePwdPresenter {
        return ChangePwdPresenter()
    }

    override fun initData() {
    }

    override fun bindView(): ChangePwdView {
        return this
    }
}